﻿namespace Vdc.Grid
{
    using System;
    using System.ComponentModel;

    public class FilterOption
    {
        private FilterOptionType _Type;
        private bool isDefault;

        public FilterOption()
        {
        }

        public FilterOption(FilterOptionType type)
        {
            this._Type = type;
        }

        internal virtual string GetID()
        {
            return ((int) this.Type).ToString();
        }

        internal virtual string GetText(Vdc.Grid.Grid grid)
        {
            switch (this.Type)
            {
                case FilterOptionType.NoFilter:
                    return grid.LocalizationSettings.FilterCriteria_NoFilter;

                case FilterOptionType.Contains:
                    return grid.LocalizationSettings.FilterCriteria_Contains;

                case FilterOptionType.DoesNotContain:
                    return grid.LocalizationSettings.FilterCriteria_DoesNotContain;

                case FilterOptionType.StartsWith:
                    return grid.LocalizationSettings.FilterCriteria_StartsWith;

                case FilterOptionType.EndsWith:
                    return grid.LocalizationSettings.FilterCriteria_EndsWith;

                case FilterOptionType.EqualTo:
                    return grid.LocalizationSettings.FilterCriteria_EqualTo;

                case FilterOptionType.NotEqualTo:
                    return grid.LocalizationSettings.FilterCriteria_NotEqualTo;

                case FilterOptionType.SmallerThan:
                    return grid.LocalizationSettings.FilterCriteria_SmallerThan;

                case FilterOptionType.GreaterThan:
                    return grid.LocalizationSettings.FilterCriteria_GreaterThan;

                case FilterOptionType.SmallerThanOrEqualTo:
                    return grid.LocalizationSettings.FilterCriteria_SmallerThanOrEqualTo;

                case FilterOptionType.GreaterThanOrEqualTo:
                    return grid.LocalizationSettings.FilterCriteria_GreaterThanOrEqualTo;

                case FilterOptionType.IsNull:
                    return grid.LocalizationSettings.FilterCriteria_IsNull;

                case FilterOptionType.IsNotNull:
                    return grid.LocalizationSettings.FilterCriteria_IsNotNull;

                case FilterOptionType.IsEmpty:
                    return grid.LocalizationSettings.FilterCriteria_IsEmpty;

                case FilterOptionType.IsNotEmpty:
                    return grid.LocalizationSettings.FilterCriteria_IsNotEmpty;
            }
            return "";
        }

        [Bindable(true), Description("Indicates whether the current filter option is the default one.")]
        public virtual bool IsDefault
        {
            get
            {
                return this.isDefault;
            }
            set
            {
                this.isDefault = value;
            }
        }

        [Description("The type of the filter option."), Bindable(true)]
        public virtual FilterOptionType Type
        {
            get
            {
                return this._Type;
            }
            set
            {
                this._Type = value;
            }
        }
    }
}

